<script setup>
import { ref } from 'vue'

//计数器
const count = ref(0)

const inc = () => {
  count.value++
}

const add = (n) => {
  count.value += n
}
</script>

<template>
  <div>
    <p>{{ count }}</p>

    <!--  1.内联/行内代码(即就是一句话的时候)-->
    <button v-on:click="count++">+1</button>

    <!--  2.调用无参函数-->
    <button v-on:click="inc()">+1</button>
    <!--  3.调用有参函数-->
    <button v-on:click="add(10)">+10</button>
    <button v-on:click="add(5)">+5</button>
    <!--   简写-->
    <button @click="add(3)">+3</button>
  </div>
</template>


<style scoped></style>